package cn.ilovese.collect.vo.user;

import cn.ilovese.collect.po.user.WorkerLevelHistory;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@NoArgsConstructor
public class WorkerLevelHistoryVO {
    private Integer id;

    //更新时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date time;

    private Integer workerLevel;

    private List<String> duration;

    private Integer reportNum;

    private Double excellentRate;

    private Double dishonestRate;

    public WorkerLevelHistoryVO(@NonNull WorkerLevelHistory workerLevelHistory){
        id=workerLevelHistory.getId();
        time=workerLevelHistory.getTime();
        workerLevel=workerLevelHistory.getWorkerLevel();
        SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        duration=new ArrayList<>();
        String startTime=df.format(workerLevelHistory.getStartTime());
        String endTime=df.format(workerLevelHistory.getEndTime());
        duration.add(startTime);
        duration.add(endTime);
    }
}
